var seconds = 0;
$(document).ready(function() { // run the plugin when the document has been rendered
	var myDiv = document.createElement('div');
	myDiv.id = "timeInPage";
	myDiv.className = "timeInPage";
	var footer = document.getElementById('footer');
	footer.appendChild(myDiv);
	setInterval(function() {computeTime()}, 1000);
});

function computeTime() {
	seconds = seconds + 1;
	var divTime = document.getElementById('timeInPage');
	divTime.innerHTML = "You've been in this page for";
	var hours = Math.floor(seconds / 3600);
	var minutes = Math.floor((seconds % 3600) / 60);
	if(hours > 0) {
		if(hours == 1) divTime.innerHTML += " 1 hour"; else divTime.innerHTML += " " + hours + " hours";
	}
	if(minutes > 0) {
		if(minutes == 1) divTime.innerHTML += " 1 minute"; else divTime.innerHTML += " " + minutes + " minutes";
	}
	if(seconds % 60 > 0) {
		if(seconds % 60 == 1) divTime.innerHTML += " 1 second"; else divTime.innerHTML += " " + (seconds % 60) + " seconds";
	}
	divTime.innerHTML .= ".";
}